//https://www.dotcpp.com/oj/contest6445_problem2.html
package 题目集.数学;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.BitSet;

/**
 * 每个数可以被分解为多个质因子，当某两个数存在公约数时，一定存在相同的质因子 
 *
 */
public class 质因数匹配 {
	static int n;
	static int maxn=(int) (1e5+10);
	static int maxV=(int) 1e6;
	static int[] src=new int[maxn];
	static int[] indexs=new int[maxV];
	
	public static void main(String[] args) {
		Reader sc=new Reader(System.in);
		n=sc.nextInt();
		for(int i=1;i<=n;i++) {
			src[i]=sc.nextInt();
		}
		int[] res=fun();
		System.out.println(res[0]+" "+res[1]);
	}
	public static int[] fun() {
		int[] res=null;
		int pre=Integer.MAX_VALUE;
		int curr=0;
		for(int i=1;i<=n;i++) {
			int cur=src[i];
			int ans=Integer.MAX_VALUE;
			for(int k=2;k<=cur/k;k++) {
				if(cur%k==0) {
					if(indexs[k]!=0&&indexs[k]!=i) {
						ans=Math.min(ans, indexs[k]);
					}
					indexs[k]=i;
					while(cur%k==0) {
						cur/=k;
					}
				}
			}
			if(ans<pre) {
				pre=ans;
				curr=i;
			}
		}
		return new int[] {pre,curr};
	}
	static class Reader {
		static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

		public Reader(Object... o) {
		}

		public int nextInt() {
			try {
				in.nextToken();
			} catch (Exception ignored) {
			}
			return (int) in.nval;
		}
	}
}
